package o;

import android.content.Context;
import android.webkit.WebView;
import com.huawei.hms.framework.network.restclient.hwhttp.RequestBody;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;

public class bau {

    interface a {
        void ˋ(JSONObject jSONObject);
    }

    static class b implements dmi {
        private Context ˊ;
        private d ˋ;
        private a ॱ;

        public b(Context context, d dVar, a aVar) {
            this.ˋ = dVar;
            this.ˊ = context;
            this.ॱ = aVar;
        }

        /* JADX WARNING: inconsistent code. */
        /* Code decompiled incorrectly, please refer to instructions dump. */
        public void run() {
            /*
            r10 = this;
            r0 = 0;
            r2 = new org.json.JSONObject;
            r2.<init>();
            r4 = java.lang.System.currentTimeMillis();
            r3 = o.dnb.ˊ();	 Catch:{ Exception -> 0x00f3, all -> 0x010f }
            r1 = "JSON";
            r6 = r10.ˋ;	 Catch:{ Exception -> 0x00f3, all -> 0x010f }
            r6 = r6.ˋ();	 Catch:{ Exception -> 0x00f3, all -> 0x010f }
            r1 = r1.equals(r6);	 Catch:{ Exception -> 0x00f3, all -> 0x010f }
            if (r1 == 0) goto L_0x00c6;
        L_0x001c:
            r1 = r10.ˊ;	 Catch:{ Exception -> 0x00f3, all -> 0x010f }
            r6 = r10.ˋ;	 Catch:{ Exception -> 0x00f3, all -> 0x010f }
            r1 = o.bau.ॱ(r1, r6);	 Catch:{ Exception -> 0x00f3, all -> 0x010f }
        L_0x0024:
            r1 = r3.ˎ(r1);	 Catch:{ Exception -> 0x00f3, all -> 0x010f }
            r0 = r1.execute();	 Catch:{ Exception -> 0x00f3, all -> 0x010f }
            r1 = o.azh.ˏ;	 Catch:{ Exception -> 0x00f3 }
            r3 = "JsPostDataHelper";
            r6 = new java.lang.StringBuilder;	 Catch:{ Exception -> 0x00f3 }
            r6.<init>();	 Catch:{ Exception -> 0x00f3 }
            r7 = "getPostData code:";
            r6 = r6.append(r7);	 Catch:{ Exception -> 0x00f3 }
            r7 = r0.ˊ();	 Catch:{ Exception -> 0x00f3 }
            r6 = r6.append(r7);	 Catch:{ Exception -> 0x00f3 }
            r6 = r6.toString();	 Catch:{ Exception -> 0x00f3 }
            r1.ˋ(r3, r6);	 Catch:{ Exception -> 0x00f3 }
            r1 = r0.ˊ();	 Catch:{ Exception -> 0x00f3 }
            r3 = 200; // 0xc8 float:2.8E-43 double:9.9E-322;
            if (r1 != r3) goto L_0x00ea;
        L_0x0052:
            r1 = "rtnCode";
            r3 = "0";
            r2.put(r1, r3);	 Catch:{ Exception -> 0x00f3 }
        L_0x0059:
            r1 = "httpStatusCode";
            r3 = r0.ˊ();	 Catch:{ Exception -> 0x00f3 }
            r3 = java.lang.String.valueOf(r3);	 Catch:{ Exception -> 0x00f3 }
            r2.put(r1, r3);	 Catch:{ Exception -> 0x00f3 }
            r1 = r0.ᐝ();	 Catch:{ Exception -> 0x00f3 }
            r1 = r1.ʽ();	 Catch:{ Exception -> 0x00f3 }
            r3 = o.dna.ˎ();	 Catch:{ Exception -> 0x00f3 }
            if (r3 == 0) goto L_0x008e;
        L_0x0074:
            r3 = o.azh.ˏ;	 Catch:{ Exception -> 0x00f3 }
            r6 = "JsPostDataHelper";
            r7 = new java.lang.StringBuilder;	 Catch:{ Exception -> 0x00f3 }
            r7.<init>();	 Catch:{ Exception -> 0x00f3 }
            r8 = "getPostData responseData:";
            r7 = r7.append(r8);	 Catch:{ Exception -> 0x00f3 }
            r7 = r7.append(r1);	 Catch:{ Exception -> 0x00f3 }
            r7 = r7.toString();	 Catch:{ Exception -> 0x00f3 }
            r3.ˋ(r6, r7);	 Catch:{ Exception -> 0x00f3 }
        L_0x008e:
            r3 = o.bau.ॱ(r1);	 Catch:{ Exception -> 0x00f3 }
            if (r3 == 0) goto L_0x0101;
        L_0x0094:
            r1 = "rtnData";
            r2.put(r1, r3);	 Catch:{ Exception -> 0x00f3 }
        L_0x0099:
            o.dnw.ˎ(r0);
        L_0x009c:
            r0 = o.azh.ˏ;
            r1 = "JsPostDataHelper";
            r3 = new java.lang.StringBuilder;
            r3.<init>();
            r6 = "getPostData, request url cost:";
            r3 = r3.append(r6);
            r6 = java.lang.System.currentTimeMillis();
            r4 = r6 - r4;
            r3 = r3.append(r4);
            r3 = r3.toString();
            r0.ˋ(r1, r3);
            r0 = r10.ॱ;
            if (r0 == 0) goto L_0x00c5;
        L_0x00c0:
            r0 = r10.ॱ;
            r0.ˋ(r2);
        L_0x00c5:
            return;
        L_0x00c6:
            r1 = "KV";
            r6 = r10.ˋ;	 Catch:{ Exception -> 0x00f3, all -> 0x010f }
            r6 = r6.ˋ();	 Catch:{ Exception -> 0x00f3, all -> 0x010f }
            r1 = r1.equals(r6);	 Catch:{ Exception -> 0x00f3, all -> 0x010f }
            if (r1 == 0) goto L_0x00de;
        L_0x00d4:
            r1 = r10.ˊ;	 Catch:{ Exception -> 0x00f3, all -> 0x010f }
            r6 = r10.ˋ;	 Catch:{ Exception -> 0x00f3, all -> 0x010f }
            r1 = o.bau.ˊ(r1, r6);	 Catch:{ Exception -> 0x00f3, all -> 0x010f }
            goto L_0x0024;
        L_0x00de:
            r1 = o.azh.ˏ;	 Catch:{ Exception -> 0x00f3, all -> 0x010f }
            r6 = "JsPostDataHelper";
            r7 = "getPostData error";
            r1.ˏ(r6, r7);	 Catch:{ Exception -> 0x00f3, all -> 0x010f }
            r1 = r0;
            goto L_0x0024;
        L_0x00ea:
            r1 = "rtnCode";
            r3 = "2";
            r2.put(r1, r3);	 Catch:{ Exception -> 0x00f3 }
            goto L_0x0059;
        L_0x00f3:
            r1 = move-exception;
            r1 = o.azh.ˏ;	 Catch:{ all -> 0x0107 }
            r3 = "JsPostDataHelper";
            r6 = "getPostData error";
            r1.ˏ(r3, r6);	 Catch:{ all -> 0x0107 }
            o.dnw.ˎ(r0);
            goto L_0x009c;
        L_0x0101:
            r3 = "rtnData";
            r2.put(r3, r1);	 Catch:{ Exception -> 0x00f3 }
            goto L_0x0099;
        L_0x0107:
            r1 = move-exception;
            r9 = r1;
            r1 = r0;
            r0 = r9;
        L_0x010b:
            o.dnw.ˎ(r1);
            throw r0;
        L_0x010f:
            r1 = move-exception;
            r9 = r1;
            r1 = r0;
            r0 = r9;
            goto L_0x010b;
            */
            throw new UnsupportedOperationException("Method not decompiled: o.bau.b.run():void");
        }
    }

    public static class d {
        private String ˊ;
        private bab ˋ;
        private String ˎ;
        private String ˏ;
        private String ॱ;

        public bab ॱ() {
            return this.ˋ;
        }

        public void ˏ(bab o_bab) {
            this.ˋ = o_bab;
        }

        public String ˎ() {
            return this.ˏ;
        }

        public void ˎ(String str) {
            this.ˏ = str;
        }

        public String ˏ() {
            return this.ॱ;
        }

        public void ˋ(String str) {
            this.ॱ = str;
        }

        public String ˊ() {
            return this.ˎ;
        }

        public void ˏ(String str) {
            this.ˎ = str;
        }

        public String ˋ() {
            return this.ˊ;
        }

        public void ॱ(String str) {
            this.ˊ = str;
        }
    }

    static void ˋ(Context context, final WebView webView, final d dVar) {
        JSONObject jSONObject = new JSONObject();
        try {
            if (doo.ˊ(context)) {
                dmq.ˏ.ॱ(new b(context, dVar, new a() {
                    public void ˋ(JSONObject jSONObject) {
                        bau.ˊ(webView, dVar.ˊ(), jSONObject.toString());
                    }
                }));
                return;
            }
            jSONObject.put("rtnCode", "1");
            ˊ(webView, dVar.ˊ(), jSONObject.toString());
        } catch (Exception e) {
            azh.ˏ.ˏ("JsPostDataHelper", "getPostData error");
        }
    }

    private static void ˊ(final WebView webView, final String str, final String str2) {
        if (webView != null && !dof.ॱ(str)) {
            webView.post(new Runnable() {
                public void run() {
                    String str;
                    if (str2 == null) {
                        str = "";
                    } else {
                        str = str2;
                    }
                    webView.loadUrl("javascript:" + str + "(" + str + ")");
                }
            });
        }
    }

    static Map<String, String> ˊ(String str) {
        Map<String, String> hashMap = new HashMap();
        if (str != null) {
            try {
                JSONObject jSONObject = new JSONObject(str);
                Iterator keys = jSONObject.keys();
                while (keys.hasNext()) {
                    String str2 = (String) keys.next();
                    hashMap.put(str2, jSONObject.get(str2).toString());
                }
            } catch (JSONException e) {
                azh.ˏ.ˏ("JsPostDataHelper", "parseWapParam  JSONException ");
            }
        }
        return hashMap;
    }

    private static fus ॱ(Context context, d dVar) {
        o.fus.a ˋ = new o.fus.a().ˎ(dVar.ˎ()).ˋ(fuw.create(null, dVar.ॱ().ˎ(context, dVar.ˎ(), ˊ(dVar.ˏ()))));
        ˋ.ˋ("content-type", "application/json;charset=UTF-8");
        return ˋ.ॱ();
    }

    private static fus ˊ(Context context, d dVar) {
        o.fus.a ˋ = new o.fus.a().ˎ(dVar.ˎ()).ˋ(fuw.create(null, dVar.ॱ().ˊ(context, dVar.ˎ(), ˊ(dVar.ˏ()))));
        ˋ.ˋ("content-type", RequestBody.HEAD_VALUE_CONTENT_TYPE_URLENCODED);
        return ˋ.ॱ();
    }

    private static JSONObject ॱ(String str) {
        try {
            return new JSONObject(str);
        } catch (Exception e) {
            azh.ˏ.ˏ("JsPostDataHelper", "getRtnJsonData not json");
            return null;
        }
    }
}
